// ---------------- extract user context -------------
var summary = document.body.innerHTML;
summary = summary.replace(/<style[\s\S]*style>/gi, ""); // filter style
summary = summary.replace(/<script[\s\S]*script>/gi, ""); // filter script
summary = summary.replace(/<[^>\n]*>/gi, ""); // filter tag
summary = summary.replace(/[\s]+/g, ""); // filer white char
summary = summary.substr(0, 500);

var context = {
	"userId" : ad_delivery_uid,
	"userIp" : ad_delivery_uip,
	"title" : document.title,
	"domain" : document.domain,
	"url" : document.URL,
	"referer" : document.referer,
	"summary" : summary
};

AdService.getAdAsHtml(1, context, onAdGot);

function onAdGot(data) {
	document.getElementById("adDiv").innerHTML = data;
}
